<%--
  Created by IntelliJ IDEA.
  User: LLg
  Date: 2022/11/7
  Time: 15:17
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Add</title>
</head>
<body>
    add
<div>
    <div style="color: red">${errorMsg}</div>
    <form action="AddTo" method="post" enctype="multipart/form-data">
        <div>
            账号:<input type="text" name="account" id="account" > <span style="color: red">${accountError}</span>
        </div>
        <div>
            真实姓名:<input type="text" name="realName"> <span style="color: red">${realNameError}</span>
        </div>
        <div>
            密码：<input type="text" name="password"> <span style="color: red">${passwordError}</span>
        </div>
        <div>
            性别： <input type="radio" name="sex" value="1"> 女
            <input type="radio" name="sex" value="2"> 男
        </div>
        <div>
            出生日期：<input type="text" name="birthday"><span style="color: red">${birthdayError}</span>
        </div>

        <div>
            电话：<input type="text" name="phone">
        </div>

        <div>
            地址：<input type="text" name="address">
        </div>

        <div>
            角色：
            <select name="roleId">
                <option value="1">管理系统员</option>
                <option value="2">店长</option>
                <option value="3">店员</option>
            </select>
        </div>
        <div>
            证件照:
            <input type="file" name="idPic">
        </div>
        <div>
            <input type="submit">
        </div>
    </form>
</div>
    <script src="${pageContext.request.contextPath}/static/layui/layui.js" charset="utf-8"></script>
<script>
    layui.use(['jquery'],function () {
        var $ = layui.$;
        $('#account').blur(function (){
            if ($('#account').val()==""){
                $('#account').next('span').text('')
                return false;
            }
            $.get('accountExists?account='+this.value,function (data){
                if (data!="true"){
                    //存在
                    $('#account').next('span').text('该账号已存在')
                }else {
                    // 不存在
                    $('#account').next('span').text('账号可用')
                }
            })
        })
    })
</script>

</body>
</html>
